import axios from 'axios'

// 获取帖子列表
export const getPosts = (params) => axios.get('/api/posts', { params })

// 置顶帖子
export const setPostTop = (postId, top = true) =>
  axios.post(`/api/posts/${postId}/top`, { top }).then(res => res.data)

// 删除帖子
export const deletePostById = (postId) =>
  axios.delete(`/api/posts/${postId}`).then(res => res.data)

// 恢复帖子
export const restorePostById = (postId) =>
  axios.post(`/api/posts/${postId}/restore`).then(res => res.data)

export const getPendingPosts = (params) => axios.get('/api/posts/pending', { params })
export const approvePost = (id) => axios.post(`/api/posts/${id}/approve`)
export const rejectPost = (id) => axios.post(`/api/posts/${id}/reject`)
export const getRejectedPosts = (params) => axios.get('/api/posts/rejected', { params })

export function getUserActivity(params) {
  return axios.get('/api/posts/user-activity', { params });
}
